<?php $this->load->module('mobile/index/header', $common);?>
<div class="content">
    <div class="list-search">
        <dl>
            <dd>
                <form action="" method="post" id="searchForm">
                    <input type="search" id="search_name" autocomplete="off" placeholder="请输入景区或城市名">
                    <a href="javascript:void(0)" class="search_btn"></a>
                </form>
            </dd>
        </dl>
    </div>

    <div id="list">
        <?php foreach ($datalist as $v) { ?>
        <a href="<?php echo $v['link']?>">
            <div class="list-item fn-clear">
                <div class="pic">
                    <img src="<?php echo $v['file_url'];?>" onerror="this.error=null;this.src='<?php echo URLPRE;?>static/public/images/nophoto.jpg'">
                </div>
                <div class="info">
                    <h5><?php echo $v['scenic_name'];?></h5>
                    <div class="i-note">
                        <p class="price">
                            <?php if (!empty($v['price'])) :?>
                                ¥<?php echo $v['price'];?><em>起</em>
                            <?php else :?>
                                电询
                            <?php endif ;?>
                        </p>
                        <p class="c_mt"><?php echo $v['address'];?></p>
                    </div>
                </div>
                <span class="arrow-right"></span>
            </div>
        </a>
        <?php }?>
    </div>

    <a href="javascript:;" class="btn-grey btn">加载更多</a>

</div>
<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">
    $(function(){
        var slid = $("#sliderimg").slider({
            loop: true
        });
        var page = <?php echo $page+1;?>;
        var keyword = '<?php echo $keyword?>';
        var url = '<?php echo site_url('mobile/scenery/index');?>';
        $('.btn-grey').click(function(){
            var $this = $(this);
            $this.text('加载中...');
            $.get(url+(url.indexOf('?')!=-1 ?'&':'/?')+'isajax=1&keyword='+keyword+'&page='+page, function(data){
                if(data.length>0){
                    var html = '';
                    for(var i =0; i<data.length; i++){
                        var item = data[i];
                        var price = '电询' ;
                        if(item.price>0){
                         price = '¥'+ item.price+'<em>起</em>'; ;
                        }
                        html += '<a href="'+ item.link +'">' +
                            '<div class="list-item fn-clear"><div class="pic">' +
                            '<img src="'+ item.file_url +'">' +
                            '</div><div class="info">' +
                            '<h5>'+ item.scenic_name +'</h5>' +
                            '<div class="i-note"><p><span class="price">'+price+'</span></p>' +
                            '<p><span>'+ item.address +'</span></p>' +
                            '</div></div><span class="arrow-right"></span></div></a>';
                    }
                    $('#list').append(html);
                    page ++;
                    $this.text('加载更多');
                }else{

                    $.dialog({
                        style:'tip',
                        width:200,
                        closeTime:1000,
                        content: '<p style="text-align: center">没有更多了</p>'
                    }).open();
                    $this.text('没有更多了');
                }

            },'json');
        });
        $('.search_btn').click(function () {
            keyword = $('#search_name').val();
            if(keyword.length> 0){
                keyword = encodeURIComponent(keyword);
                window.location.href = url+(url.indexOf("?") > -1 ? "&" : "?")+'keyword='+keyword;
            }
        });
    });
</script>